package com.ask.controller;

import com.ask.entity.User;
import com.ask.properties.Company;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/books")
public class BookController {

    @Value("${lesson}")
    private String lesson;

    @Autowired
    private Environment environment;

    @Autowired
    private Company company;


    @GetMapping("/getById")
    public String getById(Integer id, HttpSession session){
        session.setAttribute("id", id);
        System.out.println("session 中存储id :" + id);
        return id.toString();
    }


    @GetMapping("/sessionId")
    public String getSession(HttpSession session){
        Object sessionId = session.getAttribute("id");
        System.out.println("session 中取到 id : " + sessionId);
        return sessionId.toString();
    }
}
